package com.baofu.paycore.service.facade.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 支付工具子类型
 * <p>
 *     1、余额
 *     2、借记卡快捷支付
 *     3、信用卡快捷支付
 *     4、个人网银
 *     5、企业网银
 * </p>
 * User: xin deng  Date: 2016/04/18 ProjectName: paycore Version: 1.0
 */
@Getter
@Slf4j
@AllArgsConstructor
public enum PayToolSubTypeEnum {

    ACCOUNT("ACCOUNT", "ACCOUNT", "余额"),

    WITHHOLD_PAY_C("WITHHOLD_PAY_C", "BANK_CARD", "信用卡代扣支付"),

    WITHHOLD_PAY_D("WITHHOLD_PAY_D", "BANK_CARD", "储蓄卡代扣支付"),

    QUICK_PAY_D("QUICK_PAY_D", "BANK_CARD", "储蓄卡快捷支付"),

    QUICK_PAY_C("QUICK_PAY_C", "BANK_CARD", "信用卡快捷支付"),

    E_BANK_PERSON_D("E_BANK_PERSON_D", "BANK_CARD", "个人网银储蓄卡"),

    E_BANK_ORG_D("E_BANK_ORG_D", "BANK_CARD", "企业网银储蓄卡"),

    E_BANK_PERSON_C("E_BANK_PERSON_C", "BANK_CARD", "个人网银信用卡"),

    E_BANK_ORG_C("E_BANK_ORG_C", "BANK_CARD", "企业网银信用卡"),

    E_BANK("E_BANK", "BANK_CARD", "网银"),

    SCAN_PAY("SCAN_PAY", "THIRD_PAY", "聚合支付"),

    APP_PAY("APP_PAY", "THIRD_PAY", "APP支付"),

    VOUCHER("VOUCHER", "VOUCHER", "代金券"),
    ;

    /**
     * 支付工具子类型编码
     */
    private String subPayToolCode;

    /**
     * 支付工具大类编码
     */
    private String payToolCode;

    /**
     * 支付工具子类型描述
     */
    private String desc;

    /**
     * 通过枚举编码获得枚举
     *
     * @param code    枚举编码
     * @return        返回编码对应的枚举类型
     */
    public static PayToolSubTypeEnum explain(String code) {
        for (PayToolSubTypeEnum payToolSubTypeEnum : values()) {
            if (payToolSubTypeEnum.getSubPayToolCode().equals(code)) {
                return payToolSubTypeEnum;
            }
        }
        return null;
    }
}

